function myNew(constructor,...args) {
    // 1.
    // const obj = {}
    // obj.__proto__ = constructor.prototype

    // 2.
    obj = Object.create(constructor.prototype)
    
    const res = constructor.apply(obj,args)
    return res instanceof Object ? res || obj : obj
}

function Person(name,age){
    this.name = name
    this.age = age
}

const person = myNew(Person,'张三',18)

console.log(person)